package buda.tabWidget;

import android.app.TabActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class TabWidgetActivity extends TabActivity implements OnClickListener{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

       TabHost mTabHost = getTabHost();
        
    /*   mTabHost.addTab(mTabHost.newTabSpec("episodesTabSpec")
    		   .setIndicator("Episodes")
    		   .setContent(R.id.episodeTab));*/
       
       TabSpec linksTabSpec = mTabHost.newTabSpec("contactTabSpec"); 
        linksTabSpec.setIndicator("Contact")
        .setContent(R.id.contactTab);
  
        mTabHost.addTab(linksTabSpec);
        mTabHost.setCurrentTab(0);
        
        
        //mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3));

        //_episodeView = (WebView)findViewById(R.id.episodeView);
        //_episodeView.setBackgroundColor(Color.BLACK);
        //_episodeView.loadUrl("http://www.twitter.com");
        
        _browseButton = (Button)findViewById(R.id.browseTheJamhole);
        _browseButton.setOnClickListener(this);
        
        _callButton = (Button)findViewById(R.id.callTheJamhole);
        _callButton.setOnClickListener(this);
        
        _emailButton = (Button)findViewById(R.id.emailTheJamhole);
        _emailButton.setOnClickListener(this);
        
        _donateButton = (Button)findViewById(R.id.donateButton);
        _donateButton.setOnClickListener(this);
        
        _twitterButton = (Button)findViewById(R.id.twitterButton);
        _twitterButton.setOnClickListener(this);
        
    }

    Button _browseButton;
    Button _callButton;
    Button _emailButton;
    Button _donateButton;
    Button _twitterButton;
    WebView _episodeView;
    
	@Override
	public void onClick(View view) {
		if(view == this._browseButton)
			startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.thejamhole.com")));
		else if(view == this._callButton)
			this.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:406-204-4687")));
		else if(view == this._emailButton)
			this.sendEmail();
		else if(view == this._donateButton)
			startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.thejamhole.com/donate")));
		else if(view == this._twitterButton)
			{
				Intent intent = new Intent();
				intent.setClassName("buda.tabWidget", "buda.tabWidget.TwitterListActivity");
				this.startActivity(intent);
				//intent.putExtra("com.android.samples.SpecialValue", "Hello, Joe!"); // key/value pair, where key needs current package prefix.
			}
	}    
	
	private void sendEmail()
	{
		Intent sendIntent = new Intent(Intent.ACTION_SEND);
	    sendIntent.setType("text");
	    sendIntent.putExtra(Intent.EXTRA_EMAIL, "info@thejamhole.com");
	    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Some feedback...");
	    sendIntent.putExtra(Intent.EXTRA_TEXT, "\n\nSend from my Android device.");
	    startActivity(Intent.createChooser(sendIntent, "Email:"));
	}
}




